# -*- coding: utf-8 -*-
import os
import sys
import time
import random

def skill_list(magic):
    skill_s = ['double_hit', 'get_dizziness', 'get_silence']
    skill_m = ['get_poison', 'get_health']
    if magic == 5:
        return skill_s
    elif magic > 5 and magic <= 10:
        list_n = skill_s + skill_m
        return list_n
    elif magic < 5 and magic > 0:
        list_n = []
        return list_n


def death_discribe(name):
    print("KO!the \033[35m%s\033[0m blood is \033[31m0\033[0m ! \033[35m%s\033[0m is dead !" % (name, name))
    return 0

def get_hurt():
    num = int(100 * random.random())
    return num

# skill fun
def double_hit(blood, magic, aggressor, sufferer):
    magic -= 4
    hurt_n = get_hurt() * 2
    if hurt_n < 100:
        hurt_n = 100
    print("\033[35m%s\033[0m use skill \033[34mDouble_hit\033[0m !!!" % aggressor)
    print( "\033[35m%s\033[0m double hit \033[31m%s\033[0m to \033[35m%s\033[0m !" % (aggressor,str(hurt_n),sufferer))
    if blood > hurt_n:
        blood -= hurt_n
        print("\033[35m%s\033[0m blood losing : \033[31m%s\033[0m" % (sufferer,hurt_n))
        print("\033[35m%s\033[0m left blood : \033[32m%s\033[0m" % (sufferer,blood))
        return blood, magic
    else:
        return 0, magic


def get_dizziness(blood, dizziness_stu, magic, aggressor, sufferer):
    dizziness_stu = 1
    magic -= 5
    hurt_n = get_hurt()
    blood -= hurt_n
    print("\033[35m%s\033[0m use skill \033[34mDizziness_hit\033[0m !!!" % aggressor)
    print('\033[35m%s\033[0m is dizziness of \033[34m%s\033[0m time! Zzz~ and get \033[31m%s\033[0m hurt' % (sufferer, dizziness_stu, hurt_n))
    return blood, dizziness_stu, magic


def fun_dizziness(dizziness_stu, sufferer):
    dizziness_stu -= 1
    if dizziness_stu > 0:
        print('\033[35m%s\033[0m is dizziness and left \033[34m%s\033[0m time! Zzz~' % (sufferer, str(dizziness_stu)))
    elif dizziness_stu ==0:
        print('\033[35m%s\033[0m is dizziness and  will be fine in next time !' % sufferer)
    return dizziness_stu


def get_silence(silence_stu, magic, aggressor, sufferer):
    silence_stu = 2
    magic -= 5
    print("\033[35m%s\033[0m use skill \033[34mSilence_hit\033[0m !!!" % aggressor)
    print( '\033[35m%s\033[0m is silence for \033[34m%s\033[0m times! ... ...' % (sufferer,str(silence_stu)))
    return silence_stu, magic


def fun_silence(silence_stu, sufferer):
    print ('\033[35m%s\033[0m is still silence and left \033[34m%s\033[0m time! ... ...' % (sufferer,str(silence_stu)))
    silence_stu -= 1
    return silence_stu


def get_poison(blood, poison_stu, magic, aggressor, sufferer):
    poison_stu = 3
    magic -= 6
    hurt_n = 50
    print("\033[35m%s\033[0m use skill \033[34mPoison_hit\033[0m !!!" % aggressor)
    print( '\033[35m%s\033[0m is poison and get \033[31m%s\033[0m hurt! @#$~\npoison state left \033[34m%s\033[0m times!'
        % (sufferer,str(hurt_n),str(poison_stu)))
    if blood > hurt_n:
        blood -= hurt_n
        print("\033[35m%s\033[0m blood losing : \033[31m%s\033[0m" % (sufferer, hurt_n))
        print("\033[35m%s\033[0m left blood : \033[32m%s\033[0m" % (sufferer, blood))
        return blood, poison_stu, magic
    else:
        death_discribe(sufferer)
        return 0, poison_stu, magic


def fun_poison(blood, poison_stu, sufferer):
    hurt_n = 50
    print('\033[35m%s\033[0m is poison and get \033[31m%s\033[0m hurt! @#$~\npoison state left \033[34m%s\033[0m times!'
        % (sufferer, str(hurt_n), str(poison_stu)))
    poison_stu -= 1
    if blood > hurt_n:
        blood -= hurt_n
        print("\033[35m%s\033[0m blood losing : \033[31m%s\033[0m" % (sufferer, hurt_n))
        print("\033[35m%s\033[0m left blood : \033[32m%s\033[0m" %(sufferer, blood))
        return blood, poison_stu
    else:
        death_discribe(sufferer)
        return 0, poison_stu


def get_health(blood, magic, aggressor):
    health_num = int(300 * random.random())
    if health_num < 150:
        health_num = 150
    blood += health_num
    magic -= 6
    print('\033[35m%s\033[0m get \033[32m%s\033[0m point health !\t+++ now blood : \033[32m%s\033[0m' % (aggressor,health_num,blood))
    return blood, magic



